package cloudnative.demo.labservice.mapper;


import cloudnative.demo.labservice.model.Laboratory;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface LaboratoryMapper {

    // 查询所有实验室
    @Select("SELECT * FROM laboratory")
    List<Laboratory> queryAllLaboratories();

    // 查询空实验室
    @Select("SELECT * FROM laboratory WHERE WorkerID IS NULL")
    List<Laboratory> queryEmptyLaboratories();

    // 通过WorkerID查询实验室
    @Select("SELECT * FROM laboratory WHERE WorkerID = #{workerId}")
    List<Laboratory> queryLaboratoriesByWorkerID(@Param("workerId") Long workerId);

    // 插入新实验室
    @Insert("INSERT INTO laboratory (WorkerID) VALUES (#{workerId})")
    void addLaboratory(@Param("workerId") Long workerId);

    // 根据ID删除实验室
    @Delete("DELETE FROM laboratory WHERE LaboratoryID = #{laboratoryId}")
    void deleteLaboratory(@Param("laboratoryId") Long laboratoryId);

    // 更新实验室信息
    @Update("UPDATE laboratory SET WorkerID = #{workerId} WHERE LaboratoryID = #{laboratoryId}")
    void updateLaboratory(@Param("laboratoryId") Long laboratoryId, @Param("workerId") Long workerId);
}
